package com.ddw.weewar.api;

import android.os.AsyncTask;

import org.apache.http.HttpResponse;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.impl.client.DefaultHttpClient;

import java.io.IOException;

/**
 * Represents the weewar api
 */
public abstract class WeewarApi {

    /**
     * Represents a callback handler for user responses
     */
    public static interface UserCallback {

        /**
         * Method called when the user is requested successfully
         * @param user the user information found
         */
        public void onSuccess(WeewarUser user);

        /**
         * Method called when the request fails
         * @param exception the exception that was raised
         */
        public void onFailure(Throwable exception);

    }

    /**
     * Makes a request for the user information
     * @param username the username to get the info for
     * @param callback the callback to respond to
     */
    public static void user(String username, UserCallback callback) {
        new WeewarUserRequest(username, callback).execute();
    }

}
